class Natureza < ActiveRecord::Base
  has_many :lancamentos
  
#  Natureza.include_root_in_json = false if Natureza.respond_to?(:include_root_in_json)
#  acts_as_nested_set

  def valores_mensais(ano=Time.new.year, meses=[1..12])
    Lancamento.sum('valor', :group => 'data', :having => ["natureza_id = ?", self.id])
  end
  
#  def self.root_nodes
#    find(:all, :conditions => 'parent_id IS NULL')
#  end
#
#  def self.find_children(start_id = nil)
#    start_id.to_i == 0 ? root_nodes : find(start_id).direct_children
#  end
#
#  def leaf
#    unknown? || all_children_count() == 0
#  end
#
#  def text
#    nome
#  end
#
#  def to_json_with_leaf(options = {})
#    self.to_json_without_leaf(options.merge(:methods => [:leaf, :text, :valores_mensais]))
#  end
#
#  alias_method_chain :to_json, :leaf

end
